package com.xiong.controller;

import com.xiong.pojo.Student;
import com.xiong.response.ResultBean;
import com.xiong.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 熊宇
 * @date 2022/4/29 15:37
 * @description student
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    /**
     * 通过姓名模糊查询学生
     * @param name
     * @return
     */
    @GetMapping("/selectStudentsByName/{name}/{pageNum}/{pageSize}")
    public ResultBean selectStudentsByName(@PathVariable("name") String name,@PathVariable("pageNum") int pageNum,@PathVariable("pageSize") int pageSize){
        return ResultBean.suc(studentService.selectStudentsByName(name,pageNum,pageSize));
    }

    /**
     * 通过性别查找学生
     * @param sex
     * @return
     */
    @GetMapping("/selectStudentsBySex/{sex}")
    public  ResultBean selectStudentsBySex(@PathVariable("sex") Byte sex){
        return ResultBean.suc(studentService.selectStudentsBySex(sex));
    }

    /**
     * 通过年级查找学生
     * @param grade
     * @return
     */
    @GetMapping("/selectStudentsByGrade/{grade}")
    public ResultBean selectStudentsByGrade(@PathVariable("grade") Integer grade){
        return ResultBean.suc(studentService.selectStudentsByGrade(grade));
    }

}
